﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace CommonLib.CameraExtend
{
	[System.Serializable]
	public class CameraInfor
	{
		/// <summary> Camera的名称	/// </summary>
		//public string m_CameraName;
		/// <summary> Camera的实体	/// </summary>
		//public Camera m_Camera;
		/// <summary> Camera的渲染顺序/// </summary>
		public int m_cameraDeepth = 0;
		/// <summary> Camra的单位米与像素转换比例/// </summary>
		public int m_PixelsToUnits = 100;

		public bool m_Orthographic = true;
		public LayerMask m_CullingMask;

		public int m_Width = 1920;
		public int m_Height = 1080;
		public bool m_isFlexible = false;
		public int m_MaxWidth = 1920;
		public int m_MaxHeight = 1080;
		public int m_MinWidth = 1920;
		public int m_MinHeight = 1080;
		public Rect m_ViewRect = new Rect(0,0,1,1);

		public AnchorType m_Anchor = AnchorType.MiddleCenter;

		public float m_Zoom = 1.0f;
		public Vector2 m_ZoomCenter = Vector2.zero;

		public void SetCameraByInfor(Camera _camera)
		{
			_camera.depth = m_cameraDeepth;
			_camera.rect = m_ViewRect;
			_camera.orthographic = m_Orthographic;
			_camera.cullingMask = m_CullingMask.value;

			if (m_Orthographic)
			{
				_camera.orthographicSize = m_MaxHeight / (m_PixelsToUnits * 2 ) / m_Zoom;
			}
		}


	}

	[System.Serializable]
	public enum AnchorType
	{
		UpperLeft = 4,
		UpperCenter = 3,
		UpperRight = 5,
		MiddleLeft = 1,
		MiddleCenter = 0,
		MiddleRight = 2,
		LowerLeft = 7,
		LowerCenter = 6,
		LowerRight = 8
	}
}